package com.example.rwq_test.anno.customAnno.EventAnnotation.hadler;

import com.example.rwq_test.anno.customAnno.EventAnnotation.EventAnnotation;
import com.example.rwq_test.anno.customAnno.EventAnnotation.EventTypeEnum;
import com.example.rwq_test.anno.customAnno.EventAnnotation.event.Event;
import com.example.rwq_test.anno.customAnno.EventAnnotation.event.Event1;
import com.example.rwq_test.util.AutoIncrementIDGenerator;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * @Description
 * @Author renweiqiang
 * @Date 2024/4/28 上午10:44
 */
@Component
@EventAnnotation(eventType = EventTypeEnum.EVENT1)
public class Event1Handler extends AbstractHandler {

    @Override
    public Event buildEvent() {
        Event1 event1 = new Event1(AutoIncrementIDGenerator.getID(), 1);
        return event1;
    }

    @Override
    public void handleEventStart(Event event) {
        super.handlePublic(event);
        doSomething(event);
    }

    @Override
    public void handleEvent(Event event) {
        System.out.println("handleEvent...");
    }

    @Override
    public void handleEventFinish(Event event) {
        System.out.println("handleEventFinish...");
    }

    private void doSomething(Event event) {
        try {
            System.out.println("doSomething...");
            TimeUnit.MILLISECONDS.sleep(50);
        } catch (InterruptedException e) {

        }
    }
}
